package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Author: WaveKing
 * @Description: TODO
 * @Date: Created in 10:22 2023/11/27
 * @Modified By:
 */
public class filecopy {
    public static void main(String[] args) {
        String file = "d:\\a.txt";
        String outfile = "e:\\a.txt";
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        Boolean loop = true;
        byte[] a = new byte[1024];
        int readLen = 0;

        try {
                fileInputStream = new FileInputStream(file);
                fileOutputStream = new FileOutputStream(outfile);
                while ((readLen = fileInputStream.read(a))!=-1){
                    fileOutputStream.write(a,0,readLen);
                }
            System.out.println("拷贝完成");
        } catch (IOException e) {
                e.printStackTrace();
            }
        finally {
            if (fileInputStream != null){
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream != null){
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }

    }
}
